Repository navigation
csnode: check quick-start checkpoints against the chain before loading them - #10
Merged
Merged
Conversation
…g them PR #71 added a chain binding to checkpoints (head.bin: sequence and head hash) and a ChainVerifier hook to CachesSerializationManager::load(), but BlockChain::tryQuickStart() calls load() without a verifier. A checkpoint saved for a block the node no longer has at that sequence (after a rollback, a fork, or caches copied from another node) is therefore loaded as is. Its wallet balances and consensus settings then silently differ from the chain the node actually holds. Pass a verifier that compares the checkpoint head hash with the block hash the node has at that sequence (BlockHashes, persisted independently of the blocks DB). On a mismatch the checkpoint is quarantined and the next older one is tried, falling back to a slow start; this is the existing behaviour for any rejected checkpoint. When the check is not possible (legacy checkpoint without head, or hash unknown locally), the checkpoint is accepted as before, so healthy nodes are never forced into a resync. The decision is in a pure helper, cs::isCheckpointOnChain(), covered by tests/csnode/checkpoint_tests.cpp (4 cases). nodetests: 123/123 pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EnzinoBB
added a commit
that referenced
this pull request
Nov 5, 2026
- setup-test: "tokens node" passes --node-key too. The wallet no longer takes the node's key from the current folder (wallet PR #7), and this wallet.toml says node_key = "off" (the answer was create), so "node" did not resolve and the {"error": ...} JSON ended in KeyError 'source'. The error is now asserted first. - setup.ps1: the command printed for later quotes only the arguments that need it (".\credits-wallet.exe --config wallet.toml account new main"), as setup.sh does; the test looks for "account new main". - both: the create option says the account is under the wallet password, one for every account, chosen with the first (wallet PRs #9/#10). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem (path C of the divergence map)
Upstream PR #71 bound checkpoints to the chain (
head.bin: sequence and head block hash) and added aChainVerifierhook toCachesSerializationManager::load(). ButBlockChain::tryQuickStart()callsload()without a verifier.A checkpoint saved for a block the node no longer has at that sequence (after a rollback, a fork, or caches copied from another node) is loaded as is. Balances and consensus settings then silently differ from the chain the node actually holds.
Fix (+20 lines in 3 files)
tryQuickStart()passes a verifier that compares the checkpoint head hash with the hash the node has at that sequence inBlockHashes, which is persisted in LMDB independently of the blocks DB.cs::isCheckpointOnChain().Tests
New
tests/csnode/checkpoint_tests.cpp, 4 cases: matching hash, different hash, unknown hash, checkpoint without head.nodetests123/123.Upstream
A single commit that applies to CREDITSCOM/node.
🤖 Generated with Claude Code